<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/statics/css/file.css">
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/statics/css/urlLink.css">
<script
	src="${pageContext.request.contextPath}/statics/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/statics/js/checkbox.js"></script>
</head>
<body>
	<div class="main_con">
		<div class="main_con_top">
			<span>全部加载，共****个</span> <span class="wj_total"><input
				type="submit" id="but" value="下载" onclick="load()"></span>
		</div>
		<div class="list-view">
			<ul>
				<li class="col first-col" style="width: 50%;"><input
					type="checkbox" class="check" id="all" onclick="selectAll(this)" />
					<span class="span_wjm">文件名</span></li>
				<li class="col time_col" style="width: 20%; margin-left: 20px"><span>修改时间</span>
				<li class="col" style="width: 15%; margin-left: 20px"><span>大小</span></li>
				<li class="col last-col" style="width: 20%;"><span></span></li>
			</ul>

		</div>
	</div>
	<div class="list-view-container">
		<c:if test="${not empty files}">
			<c:forEach items="${files }" var="file">
				<ul id="choose">
					<li class="col1" style="width: 50%;"><input type="checkbox"
						class="check" onclick="cl()" name="ab" value="${file.fileId}" />
						<span class="span_wjm">${file.fileName}</span> <input
						type="hidden" id="fileId" value="${file.fileId }" /> <a href="#"
						style="float: right"><span><i class="fa fa-share-alt"></i></span></a>
						<a href="download?fileName=${file.fileName }" style="float: right"><span><i
								class="fa fa-download"></i></span></a> <a href="#" style="float: right"><span><i
								class="fa fa-trash"></i></span></a></li>

					<li class="col1 time_col" style="width: 20%; margin-left: 20px"><span>${file.upTime}</span></li>
					<li class="col1" style="width: 15%; margin-left: 20px"><span>${file.fileSize}</span></li>
					<li class="col1 last-col" style="width: 20%;"><span></span></li>
				</ul>
			</c:forEach>
		</c:if>

		<c:forEach items="${sessionScope.folder }" var="folder">
			<ul>
				<li class="col1 first-col1" style="width: 50%;"><input
					type="checkbox" class="check" /> <input type="hidden" id="fileId"
					value="${folder.folderId}" /> <span class="span_wjm"><i
						class="fa fa-folder"></i><a href="folderList2/${folder.folderId}"
						style="">${folder.foleName}</a></span> <a href="" style="float: right"><span><i
							class="fa fa-share-alt"></i></span></a> <a href="" style="float: right"><span><i
							class="fa fa-download"></i></span></a> <a href="" style="float: right"><span><i
							class="fa fa-trash"></i></span></a></li>

				<li class="col1 time_col" style="width: 20%; margin-left: 20px"><span>1</span></li>
				<li class="col1" style="width: 15%; margin-left: 20px"><span>2</span></li>
				<li class="col1 last-col" style="width: 20%;"><span> </span></li>

			</ul>
		</c:forEach>

	</div>
	<br>
	<div style="display: none;" id="meuID">
		<fmt:formatNumber type="number"
			value="${(1024*1024*10 - sessionScope.used_size)/(1024*1024)}"
			pattern="0.00" maxFractionDigits="2" />
	</div>
	<br>
	<!-- <<<<<<< Updated upstream
======= -->
	<div class="mask">
		<div class="box">
			<span class="close">X</span>
			<form id="Form">
				<a href="#" id="shareUrlId" target="_blanck">分享链接</a>
			</form>
		</div>
	</div>
	<!-- >>>>>>> Stashed changes -->
</body>
<script
	src="${pageContext.request.contextPath}/statics/js/jquery.min.js"></script>
<script type="text/javascript">
	function show(data) {
		console.log("fileUrl:" + data);
		window.open('${pageContext.request.contextPath}/show_attach?fileUrl='
				+ data);
	}
	$(function() {
		//删除文件
		$(".fa-trash")
				.on(
						'click',
						function() {
							var $fileId = $(this).parents("li").find("#fileId")
									.val();
							var $fileName = $(this).parents("li").find(
									".span_wjm").text();
							console.log($fileId + "," + $fileName);
							if (confirm("你确定要删除" + $fileName)) {
								$
										.ajax({
											url : "${pageContext.request.contextPath}/delFileByFileId",
											type : "post",
											data : JSON.stringify({
												'fileId' : $fileId,
												time : new Date().toString()
											}),
											contentType : 'application/json;charset=utf-8',
											async : true, //或false,是否异步
											success : function(msg) {
												console.log(msg);
												if (msg == "ok") {
													window.location.href = "${pageContext.request.contextPath}/showFile?typeId=0";
												}
											},
											error : function(xhr) {
												alert(xhr.status)
											}
										});
							}
						});

		var $used_memoSize = $("#meuID").text();
		$(".c_leave", parent.document).text($used_memoSize + "  MB");
	});
</script>

<script type="text/javascript">
	function show(data) {
		console.log("fileUrl:" + data);
		window.open('${pageContext.request.contextPath}/show_attach?fileUrl='
				+ data);
	}
	$(function() {
		//分享文件
		$(".fa-share-alt")
				.on(
						'click',
						function() {
							var $fileId = $(this).parents("li").find("#fileId")
									.val();
							var $fileName = $(this).parents("li").find(
									".span_wjm").text();
							console.log($fileId + "," + $fileName);
							if (confirm("你确定要分享" + $fileName)) {
								$
										.ajax({
											url : "${pageContext.request.contextPath}/shareFileByFileId",
											type : "post",
											data : JSON.stringify({
												'fileId' : $fileId,
												time : new Date().toString()
											}),
											contentType : 'application/json;charset=utf-8',
											async : true, //或false,是否异步
											success : function(msg) {
												console.log(msg);
												if (msg == "ok") {
													window.location.href = "${pageContext.request.contextPath}/showFile?typeId=0";
												}
											},
											error : function(xhr) {
												alert(xhr.status)
											}
										});
							}
						});

		var $used_memoSize = $("#meuID").text();
		$(".c_leave", parent.document).text($used_memoSize + "  MB");
	});
	/* =======
	
	 $(".close").click(function(){
	 $(".mask").removeClass("maskShow")
	 })
	 }); 
	
	 function shareUrl(fileId){
	 console.log(fileId);
	 $.ajax({
	 url : "${pageContext.request.contextPath}/returnUrl",
	 type : "post",
	 data : JSON.stringify({'fileId':fileId}),
	 contentType : 'application/json;charset=utf-8',
	 async : false,
	 success : function(msg) {
	 //alert(msg);
	 $("#Form>#shareUrlId").attr("href","http://localhost:8080/yun/s/"+msg+"");
	 $("#Form>#shareUrlId").text("http://localhost:8080/yun/s/"+msg+"");
	 }
	 });
	 $(".mask").addClass("maskShow");
	 }
	 >>>>>>> Stashed changes */
</script>
</html>